package com.frankle.mybatisplusgenerator;

import java.util.concurrent.ConcurrentHashMap;

import com.frankle.mybatisplusgenerator.constant.StageView;
import com.frankle.mybatisplusgenerator.utils.I18N;
import com.frankle.mybatisplusgenerator.utils.ViewUtils;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;

public class App extends Application {
	
	public static final ConcurrentHashMap<StageView, Stage> STAGE_MAP = new ConcurrentHashMap<StageView, Stage>();
	
	@Override
	public void start(Stage primaryStage) throws Exception {
		Pane pane = ViewUtils.loadView(StageView.MAIN_VIEW);
		Scene root = new Scene(pane, pane.getPrefWidth(), pane.getPrefHeight());
		root.getStylesheets().add(getClass().getResource("/css/app.css").toExternalForm());
		primaryStage.setScene(root);
		primaryStage.titleProperty().bind(I18N.createStringBinding("app.name"));;
		primaryStage.setResizable(false);
		primaryStage.setWidth(pane.getPrefWidth() + 200);
		primaryStage.setHeight(pane.getPrefHeight() + 100);
		primaryStage.getIcons().add(new Image(getClass().getResourceAsStream("/images/logo.png")));
		
		STAGE_MAP.put(StageView.MAIN_VIEW, primaryStage);
		primaryStage.show();
	}
}
